//
//  LJNHRuleTableViewCell.m
//  HACDispatcher
//
//  Created by Chengjie on 2019/9/4.
//  Copyright © 2019 Happy. All rights reserved.
//

#import "LJNHRuleTableViewCell.h"
#import <Masonry/Masonry.h>

@interface LJNHRuleTableViewCell ()
@property (nonatomic, strong) UILabel *ruleTitleLable;
@property (nonatomic, strong) UILabel *ruleContentLable;
@property (nonatomic, strong) UIView *lineView;
@end

@implementation LJNHRuleTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self didInitialize];
    }
    return self;
}

- (void)didInitialize {
    [self configSubViews];
    [self configViewsLayout];
}

- (void)configSubViews {
    [self.contentView addSubview:self.ruleTitleLable];
    [self.contentView addSubview:self.ruleContentLable];
    [self.contentView addSubview:self.lineView];
}

- (void)configViewsLayout {
    [self.ruleTitleLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).offset(20);
        make.height.equalTo(@(25));
        make.left.equalTo(self.contentView.mas_left).offset(20);
        make.right.equalTo(self.contentView.mas_right).offset(-20);
    }];
    
    [self.ruleContentLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.ruleTitleLable.mas_bottom).offset(10);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-20);
        make.left.equalTo(self.contentView.mas_left).offset(20);
        make.right.equalTo(self.contentView.mas_right).offset(-20);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView.mas_bottom);
        make.height.equalTo(@(0.5));
        make.left.equalTo(self.contentView.mas_left).offset(20);
        make.right.equalTo(self.contentView.mas_right).offset(-20);
    }];
}


- (void)configCellModel:(LWXPrivateCustomerInfoIntegrityRuleCellModel *)entity {
    self.ruleTitleLable.text = entity.title;
    self.ruleContentLable.text = entity.content;
    self.lineView.hidden = entity.hiddenBottomLine;
}


#pragma mark - getter

- (UILabel *)ruleTitleLable {
    if (!_ruleTitleLable) {
        _ruleTitleLable = [UILabel new];
        _ruleTitleLable.font = [UIFont fontWithName:@"PingFangSC-Medium" size:20];
        _ruleTitleLable.textColor = [UIColor blackColor];
        _ruleTitleLable.textAlignment = NSTextAlignmentLeft;
    }
    return _ruleTitleLable;
}

- (UILabel *)ruleContentLable {
    if (!_ruleContentLable) {
        _ruleContentLable = [UILabel new];
        _ruleContentLable.numberOfLines = 0;
        _ruleContentLable.font = [UIFont systemFontOfSize:15];
        _ruleContentLable.textColor = [UIColor grayColor];
        _ruleContentLable.textAlignment = NSTextAlignmentLeft;
    }
    return _ruleContentLable;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [UIView new];
        _lineView.backgroundColor = [UIColor grayColor];
    }
    return _lineView;
}

@end



@implementation LWXPrivateCustomerInfoIntegrityRuleCellModel

- (CGFloat)cellHeight {
    return UITableViewAutomaticDimension;
}

- (NSString *)reusableIdentifier {
    return NSStringFromClass([LJNHRuleTableViewCell class]);
}


@end
